package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.maturityDataPojo;
import com.example.pojo.outputFileDataPojo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:maturityManageMapp
 * Description:
 *
 * @Author 赵永峰
 * @Create 2025/3/11 16:16
 * @Version 1.0
 */
@Mapper
public interface maturityManageMapp {
    //辅助函数：根据字段名，去搜索等于这个字段数据的所有数据,多个字段，用的是并且。现在写好的是根据一个字段搜索,并且赋值给成熟度管理的总表
    @DS("newMscLowCodeFormal")
    @Select("select * from maturity_data where ${firstFiledName}=#{firstFiledVal} and sys_deleted=1 ORDER BY sequence_number ASC")
    List<maturityDataPojo> inquiryFiledSeveralAnd(String firstFiledName, String firstFiledVal);
    //插入一条项目数据，可以用在所以的插入一行中，已经设置了所有的字段
    @DS("newMscLowCodeFormal")
    @Insert("insert into maturity_data (" +
            "create_time, update_time, creator, " +
            "process_status, sys_update_user, sys_audit_user, " +
            "sys_audit_time, sys_deleted, project, " +
            "process_element, sub_element, quest_type, " +
            "question_form, execution_example, " +
            "score, reference_file, measures, " +
            "output, sequence_number, " +
            "id, quality_system) " +
            "VALUES (" +
            "#{create_time},#{update_time},#{creator}," +
            "#{process_status},#{sys_update_user},#{sys_audit_user}," +
            "#{sys_audit_time},#{sys_deleted},#{project}," +
            "#{process_element},#{sub_element},#{quest_type}," +
            "#{question_form},#{execution_example}," +
            "#{score},#{reference_file},#{measures}," +
            "#{output},#{sequence_number}," +
            "#{id},#{quality_system})")
    void insertOne(maturityDataPojo maturityDataPojo);
    //辅助函数：根据Id，修改一个字段的值
    @DS("newMscLowCodeFormal")
    @Update("update maturity_data set ${fieldName}=#{fieldVal} where idUse=#{id}")
    void editOneFieldById(int id, String fieldName, String fieldVal);
    //辅助函数：对输出物部分插入一行数据，向后端发送数据
    @DS("newMscLowCodeFormal")
    @Insert("INSERT INTO output_file_data SET establishTime = #{establishTime}, updateTime = #{updateTime}, deleteSign = #{deleteSign}, editName = #{editName}, filedName = #{filedName}, filedType = #{filedType}, outputDate = #{outputDate}, department = #{department}, systemId = #{systemId}, outputEndDate = #{outputEndDate}")
    void insetOneOutputFile(outputFileDataPojo pojo);
    //辅助函数：对输出物所有的信息筛选出来
    @DS("newMscLowCodeFormal")
    @Select("select * from output_file_data")
    List<outputFileDataPojo> inquiryOutputFileAll();
}
